﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using School;

namespace TestSchool
{
    [TestClass]
    public class ISchoolTest
    {
        Mock<ISchool> schoolMock;

        public ISchoolTest()
        {
            schoolMock = new Mock<ISchool>();
            string studentName = "Veselin";
            int studentNumber = 10000;
            Student student = new Student(studentName, studentNumber);
            Exam exam = Exam.Math;
            double grade = 6.5;

            schoolMock.Setup(school => school.AddExamResults(
                student, exam, grade)).Throws(new ArgumentOutOfRangeException());
            schoolMock.Setup(school => school.AddExamResults(
                null, It.IsAny<Exam>(), It.IsAny<double>())).Throws(new ArgumentNullException());
            schoolMock.Setup(school => school.GetExamResults(null)).Throws(new ArgumentNullException());
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void TestAddExamResults_InvalidGrade()
        {
            ISchool school = schoolMock.Object;
            string studentName = "Veselin";
            int studentNumber = 10000;
            Student student = new Student(studentName, studentNumber);
            Exam exam = Exam.Math;
            double grade = 6.5;

            school.AddExamResults(student, exam, grade);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TestAddExamResults_NullStudent()
        {
            ISchool school = schoolMock.Object;
            Exam exam = Exam.Math;
            double grade = 4;

            school.AddExamResults(null, exam, grade);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TestGetExamResults_NullStudent()
        {
            ISchool school = schoolMock.Object;
            school.GetExamResults(null);
        }
    }
}
